package com.dtx.day5.day05Inherit;

import com.dtx.day1.service.impl.GoodsServiceImpl;
import org.junit.Test;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;

public class TestInherit {

    @Test
    public void test2(){

        // 获取类对象
        Class<Demo> clazz = Demo.class;

        // 获取 其 继承的 父类
        Class<? super Demo> superclass = clazz.getSuperclass();
        System.out.println(superclass);

        // 获取 带有泛型的 父类
        ParameterizedType genericSuperclass = (ParameterizedType)clazz.getGenericSuperclass();
        System.out.println(genericSuperclass);
        System.out.println(genericSuperclass.getClass().getName());

        Type[] actualTypeArguments = genericSuperclass.getActualTypeArguments();

        System.out.println(actualTypeArguments[0].getTypeName());

        Class<GoodsServiceImpl> clz = GoodsServiceImpl.class;

        // 获取 接口
        Class<?>[] interfaces = clz.getInterfaces();

        System.out.println(Arrays.toString(interfaces));

        // 获取 带有泛型的接口
        Type[] genericInterfaces = clz.getGenericInterfaces();
    }
}
